package cn.zwx.search.common.enums;


import java.util.Objects;

/**
 * @description 返回错误码
 * @return
 * @author zhangwenxue
 * @createTime 2020/10/24 10:22
 **/
public enum RetCode {

    //系统返回码
    SUCCESS("000000", "处理成功"),
    FAILED("999998", "处理失败"),
    //app请求
    SIGN_ERROR("100002", "签名错误"),
    JSON_CONVERT_ERROR("100003", "JSON转换异常"),
    TIME_OUT("100004", "请求时间间隔过长"),
    PARAM_TYPE_ERROR("100005", "请求参数类型错误"),
    PARAM_ERROR("100006", "请求参数错误");


    /**
     * 错误码
     */
    private String code;

    /**
     * 错误描述
     */
    private String msg;

    RetCode(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static RetCode getRetCode(String code) {
        for (RetCode nameEnum : values()) {
            if (Objects.equals(nameEnum.getCode(), code)) {
                return nameEnum;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
